package net.lab1024.sa.admin.module.business.shop.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import net.lab1024.sa.admin.module.business.shop.domain.ShopTree;
import net.lab1024.sa.admin.module.business.shop.domain.ShopVO;
import net.lab1024.sa.admin.module.business.shop.domain.form.ShopAddForm;
import net.lab1024.sa.admin.module.business.shop.domain.form.ShopQueryForm;
import net.lab1024.sa.admin.module.business.shop.domain.form.ShopUpdateForm;
import net.lab1024.sa.admin.module.business.shop.service.ShopService;
import net.lab1024.sa.base.common.controller.SupportBaseController;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.constant.SwaggerTagConst;
import org.springframework.web.bind.annotation.*;


import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 配置
 *
 * @Author 1024创新实验室-主任: 卓大
 * @Date 2022-03-14 20:46:27
 
 
  * @Copyright  cpedu
 */
@Tag(name = SwaggerTagConst.Support.CONFIG)
@RestController
public class ShopController extends SupportBaseController {

    @Resource
    private ShopService shopService;

    @Operation(summary = "分页商品信息")
    @PostMapping("/shop/query")
    @SaCheckPermission("support:shop:query")
    public ResponseDTO<PageResult<ShopVO>> queryShopPage(@RequestBody @Valid ShopQueryForm shopqueryForm) {
        return shopService.queryShop(shopqueryForm);
    }
    @Operation(summary = "分页商品信息")
    @PostMapping("/shop/queryTree")
    @SaCheckPermission("support:shop:query")
    public ResponseDTO<List<ShopTree>> queryShopTree() {
        return shopService.queryShopTree();
    }
    @Operation(summary = "添加商品信息  ")
    @PostMapping("/shop/add")
    @SaCheckPermission("support:shop:add")
    public ResponseDTO<String> addShop(@RequestBody @Valid ShopAddForm shopAddForm) {
        return shopService.add(shopAddForm);
    }

    @Operation(summary = "修改商品参数  ")
    @PostMapping("/shop/update")
    @SaCheckPermission("support:shop:update")
    public ResponseDTO<String> updateSp(@RequestBody @Valid ShopUpdateForm updateForm) {
        return shopService.updateShop(updateForm);
    }
    @Operation(summary = "删除商品信息  ")
    @PostMapping("/shop/delete")
    @SaCheckPermission("support:shop:delete")
    public ResponseDTO<String> deleteSp(@RequestBody @Valid ShopUpdateForm updateForm) {
        return shopService.deleteShop(updateForm);
    }

}
